import axios from '~/plugins/axios';

//店铺认证--列表查询： @params: shopNanme  timeBegin timeEnd phone status pageSize pageNum
export const getShopSearchList =  function({ commit, state }, preload)  {
	return axios.post(process.env.baseUrl + '/admin/certify/list.do',preload||{})
	.catch(function (error) {	
    });
};
//店铺认证--通过认证： @params: shopId
export const certificationPass =  function({ commit, state }, preload)  {
	return axios.post(process.env.baseUrl + '/admin/certify/list.do',preload||{})
	.catch(function (error) {	
    });
};
//店铺认证--不通过认证： @params: shopId
export const certificationFail =  function({ commit, state }, preload)  {
	return axios.post(process.env.baseUrl + '/admin/certify/list.do',preload||{})
	.catch(function (error) {	
    });
};


//店铺明细--列表查询： @params: shopName phone email serverStatus  shopStatus registerTimeBegin registerTimeEnd 
export const getShopManageSearchList =  function({ commit, state }, preload)  {
    return axios.get(process.env.baseUrl + '/admin/shop/list',{params:preload})
        .catch(function (error) {
        });
};
//店铺明细--下载列表： @params: shopName phone email serverStatus  shopStatus registerTimeBegin registerTimeEnd 
// export const downLoadShopManageList =  function({ commit, state }, preload)  {
//     let arr = [];
//     let key;
//     var token = window.localStorage.getItem('token');
//     for(key in preload){
//         console.log(key)
//         arr.push(key+'='+preload[key])
//     }
//     arr.push('token='+token);
//     var p =arr.join("&");
//     var a = document.createElement('a');
//     a.href = process.env.baseUrl + '/admin/shop/down?'+p;
//     a.target = '_blank';
//     a.id='exppub';
//     document.body.appendChild(a);
//     var alink = document.getElementById('exppub');
//     alink.click();
//     alink.parentNode.removeChild(a);
// };
//店铺明细--强制关店： @params: shopId
export const forcedCloseShop =  function({ commit, state }, preload)  {
    return axios.get(process.env.baseUrl + '/admin/shop/close',{params:preload})
        .catch(function (error) {
        });
};
//店铺明细--店铺合同详情： @params: shopId
export const getShopDetail =  function({ commit, state }, preload)  {
    return axios.get(process.env.baseUrl + '/admin/shopcontract/get',{params:preload})
        .catch(function (error) {
        });
};
//店铺明细--修改店铺合同详情： @params: shopId
export const udapteShopOutTrade =  function({ commit, state }, preload)  {
    return axios.post(process.env.baseUrl + '/admin/shopcontract/udapte',preload||{})
        .catch(function (error) {
        });
};

//买家管理--列表查询： @params: shopName phone email serverStatus  shopStatus registerTimeBegin registerTimeEnd 
export const getBuyerSearchList =  function({ commit, state }, preload)  {
    return axios.get(process.env.baseUrl + '/admin/shop/list',{params:preload})
        .catch(function (error) {
        });
};

//营销管理
//分销裂变： @params: shopId:'',pageNum,pageSize,goodsId,highCommission,lowCommission,startTime,endTime
export const getShareProductList =  function({ commit, state }, preload)  {
    return axios.get(process.env.baseUrl + '/b2c/marketing/fission/list',{params:preload})
        .catch(function (error) {
        });
};
//限时折扣列表： @params: shopId:'',pageNum,pageSize
export const getDiscountActiveList =  function({ commit, state }, preload)  {
    return axios.get(process.env.baseUrl + '/b2c/marketing/discount/list',{params:preload})
        .catch(function (error) {
        });
};
//限时折扣详情： @params: shopId:'',pageNum,pageSize
export const getDiscountActiveDetail =  function({ commit, state }, preload)  {
    return axios.get(process.env.baseUrl + '/b2c/marketing/discount/detail/get',{params:preload})
        .catch(function (error) {
        });
};
//满减送： @params: shopId:'',pageNum,pageSize
export const getCouponActiveList =  function({ commit, state }, preload)  {
    return axios.get(process.env.baseUrl + '/b2c/marketing/coupon/list',{params:preload})
        .catch(function (error) {
        });
};
//满减送详情： @params: shopId:'',pageNum,pageSize
export const getCouponActiveDetail =  function({ commit, state }, preload)  {
    return axios.get(process.env.baseUrl + '/b2c/marketing/coupon/detail/get',{params:preload})
        .catch(function (error) {
        });
};
//优惠宝： @params: shopId:'',pageNum,pageSize
export const getEntryGiftActiveList =  function({ commit, state }, preload)  {
    return axios.get(process.env.baseUrl + '/b2c/marketing/couponShop/list',{params:preload})
        .catch(function (error) {
        });
};
//优惠宝： @params: shopId:'',pageNum,pageSize
export const getEntryGiftActiveDetail =  function({ commit, state }, preload)  {
    return axios.get(process.env.baseUrl + '/b2c/marketing/couponShop/detail/get',{params:preload})
        .catch(function (error) {
        });
};
//活动产品列表：活动ID： @params: id
export const getActiveProductsList =  function({ commit, state }, preload)  {
    return axios.get(process.env.baseUrl + '/admin/shop/list',{params:preload})
        .catch(function (error) {
        });
};
